//
//  PostImageCell.m
//  LiveStar
//
//  Created by 漪珊 on 2017/5/11.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "PostImageCell.h"

@implementation PostImageCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.pictureImageView];
        [self addSubview:self.deleteBtn];
    }
    return self;
}

- (UIImageView *)pictureImageView
{
    if (!_pictureImageView) {
        _pictureImageView = [[UIImageView alloc] initWithFrame:self.bounds];
        _pictureImageView.contentMode = UIViewContentModeScaleAspectFill;
        _pictureImageView.clipsToBounds = YES;
        
    }
    return _pictureImageView;
}

- (UIButton *)deleteBtn {
    
    if (!_deleteBtn) {
        _deleteBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.pictureImageView.width-15 , -12, 40 , 40)];
        _deleteBtn.userInteractionEnabled = YES;
        _deleteBtn.backgroundColor = [UIColor redColor];
        [_deleteBtn setImage:[UIImage imageNamed:@"deleteImage"] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(deletSelectedImage:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleteBtn;
}

//
- (void)deletSelectedImage:(UIButton *)sender {
    if (self.deleteImageAction) {
        self.deleteImageAction();
    }
}


@end
